<div class="uk-layui-form">
	<form class="layui-form" action="/admin/weixin/imr/save.html?said=${snsAccount.id!''}" method="post">
		<div class="layui-collapse">
			<div class="layui-colla-item">
				<h2 class="layui-colla-title">关键词指令</h2>
				<div class="layui-colla-content layui-show">
					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">指令名称：</label>
							<div class="layui-input-inline">
								<input type="text" name="name" autocomplete="off"	class="layui-input" lay-verify = "required">
							</div>
						</div>
						<div class="layui-inline">
							<font color="red">*（必填项）</font>
						</div>
						<div class="layui-inline">
							<label class="layui-form-label" style="width:90px;">触发条件：</label>
							<div class="layui-input-inline" style="width:330px;margin-right:0px;padding-top:9px;">
								<input type="radio" name="matcherule" lay-filter="keyword" value="keyword" title="关键词" checked>
      							<input type="radio" name="matcherule" lay-filter="message" value="message" title="消息类型">
      							<input type="radio" name="matcherule" lay-filter="event" value="event" title="事件类型">
							</div>
						</div>
					</div>
					
					<div class="layui-form-item" style="display:none;" id="in_message">
						<div class="layui-inline">
							<label class="layui-form-label">消息类型：</label>
							<div class="layui-input-inline">
								<select name="messagetype" id="messagetype">
									<option value="">请选择消息类型</option>
									<option value="text">文本</option>
									<option value="image">图片</option>
									<option value="voice">语音</option>
									<option value="video">视频</option>
									<option value="location">地理位置</option>
								</select>
							</div>
						</div>
						<div class="layui-inline">
							<font color="red">*（必填项）</font> 
						</div>
					</div>
					
					<div class="layui-form-item" style="display:none;" id="in_event">
						<div class="layui-inline">
							<label class="layui-form-label">事件类型：</label>
							<div class="layui-input-inline">
								<select name="eventype" lay-filter="event" id="eventype" >
									<option value="">请选择事件类型</option>
									<option value="subscribe">关注</option>
									<option value="click">自定义菜单</option>
								</select>
							</div>
						</div>
						<div class="layui-inline">
							<font color="red">*（必填项）</font> 
						</div>
					</div>
					
					<div class="layui-form-item" id="in_keyword">
						<div class="layui-inline">
							<label class="layui-form-label">关键词：</label>
							<div class="layui-input-inline">
								<input type="text" name="keyword" autocomplete="off" class="layui-input" id="keyword">
							</div>
						</div>
						<div class="layui-inline">
							<font color="red">*（必填项）</font> 
						</div>
					</div>
				</div>
			</div>
			
			
			<div class="layui-colla-item">
				<h2 class="layui-colla-title">关键词响应</h2>
				<div class="layui-colla-content layui-show">
					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">响应类型：</label>
							<div class="layui-input-inline" style="width:560px;padding-top:9px;">
								<input type="radio" lay-filter="text" name="adapter" value="text" title="回复文本消息" checked>
								<!-- 
      							<input type="radio" lay-filter="media" name="adapter" value="media" title="回复多媒体消息">
      							 -->
      							<input type="radio" lay-filter="agent" name="adapter" value="agent" title="转人工坐席">
      							<#if models?? && models["xiaoe"]?? && models["xiaoe"] == true>
      							<input type="radio" lay-filter="xiaoe" name="adapter" value="xiaoe" title="智能机器人">
      							</#if>
      							<!-- 
      							<input type="radio" lay-filter="inter" name="adapter" value="inter" title="访问接口">
      							 -->
							</div>
						</div>
					</div>
					<div class="layui-form-item" id="res_text">
						<div class="layui-inline">
							<label class="layui-form-label">文本消息：</label>
							<div class="layui-input-inline" style="width:auto;padding-top:9px;">
								<div class="layui-input-block" style="width:715px;padding-top:9px;">
									<textarea name="memo" placeholder="请输入" class="layui-textarea"></textarea>
								</div>
							</div>
						</div>
						
					</div>
					<#if models?? && models["xiaoe"]?? && models["xiaoe"] == true>
					<div class="layui-form-item" id="xiaoe_xiaoe" style="display:none;">
						<div class="layui-inline">
							<label class="layui-form-label">接入机器人：</label>
							<div class="layui-input-inline" style="width:auto;padding-top:9px;">
								<div class="layui-input-block" style="width:215px;padding-top:9px;">
									<select name="plugin">
										<option value="">请选择默认接入机器人</option>
										<#if serviceAiList??>
										<#list serviceAiList as serviceAi>
										<option value="${serviceAi.id!''}">${serviceAi.name!''}</option>
										</#list>
										</#if>
									</select>
								</div>
							</div>
						</div>
						
					</div>
					</#if>
					
					<div class="layui-form-item" id="res_skill" style="display:none;">
						<div class="layui-inline">
							<label class="layui-form-label">接待方式：</label>
							<div class="layui-input-inline" style="width:285px;padding-top:9px;height:45px;">
								<input type="radio" lay-filter="agent_default" name="interfacetype" value="default" title="默认" checked>
	      						<input type="radio" lay-filter="agent_skill" name="interfacetype" value="skill" title="技能组">
	      						<input type="radio" lay-filter="agent_agent" name="interfacetype" value="agent" title="坐席">
							</div>
						</div>
						
						<div class="layui-inline" id="agent_skill" style="display:none;">
							<label class="layui-form-label" style="width:90px;">选择技能组：</label>
							<div class="layui-input-inline" style="width:330px;margin-right:0px;padding-top:9px;">
								<select name="interfaceparam">
									<option value="">请选择技能组</option>
									<#if skillList??>
									<#list skillList as skill>
									<option value="${skill.id!''}">${skill.name!''}</option>
									</#list>
									</#if>
								</select>
							</div>
						</div>
						
						<div class="layui-inline" id="agent_agent" style="display:none;">
							<label class="layui-form-label" style="width:90px;">选择坐席：</label>
							<div class="layui-input-inline" style="width:330px;margin-right:0px;padding-top:9px;">
								<select name="interfaceurl">
									<option value="">请选择坐席</option>
									<#if skillList??>
									<#list skillList as skill>
									<optgroup label="${skill.name!''}">
										<#if agentList??>
										<#list agentList as agent>
										<#if agent.organ?? && agent.organ == skill.id>
										<option value="${agent.id!''}">${agent.username!''}（${agent.uname!''}）</option>
										</#if>
										</#list>
										</#if>
									</optgroup>
									</#list>
									</#if>
								</select>
							</div>
						</div>
					</div>
				</div>
			</div>
			
		</div>

		<div class="layui-form-button">
			<div class="layui-button-block">
				<button class="layui-btn" lay-submit>保存</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</form>
</div>
<script>
	$(function(){
		$('#keyword').attr('lay-verify','required');//关键词必输项
	});
	layui.use('form', function(){
	  var form = layui.form;
	  form.render();
	  form.on('radio(keyword)' , function(data){//关键词
		  $('#in_keyword').show();
		  $('#in_message').hide();
		  $('#in_event').hide();
		  
		  $('#messagetype').removeAttr('lay-verify');//消息类型-必输项
		  $('#eventype').removeAttr('lay-verify');//事件类型-必输项
		  $('#keyword').attr('lay-verify','required');//关键词+必输项
	  })
	  form.on('radio(message)' , function(data){//消息类型
		  $('#in_keyword').hide();
		  $('#in_message').show();
		  $('#in_event').hide();
		  
		  $('#messagetype').attr('lay-verify','required');//消息类型+必输项
		  $('#eventype').removeAttr('lay-verify');//事件类型-必输项
		  $('#keyword').removeAttr('lay-verify');//关键词-必输项
	  })
	  form.on('radio(event)' , function(data){//事件类型
		  $('#in_keyword').hide();
		  $('#in_message').hide();
		  $('#in_event').show();
		  
		  $('#messagetype').removeAttr('lay-verify');//消息类型-必输项
		  $('#eventype').attr('lay-verify','required');//事件类型+  必输项
		  $('#keyword').removeAttr('lay-verify');//关键词-必输项
	  })
	  /*******回复消息类型******/
	  form.on('radio(text)' , function(data){
		  $('#res_text').show();
		  $('#res_inter').hide();
		  $('#res_skill').hide();
		  $('#xiaoe_xiaoe').hide();
	  })
	  form.on('radio(media)' , function(data){
		  $('#res_text').hide();
		  $('#res_inter').hide();
		  $('#res_skill').hide();
	  })
	  form.on('radio(agent)' , function(data){
		  $('#res_text').hide();
		  $('#res_inter').hide();
		  $('#res_skill').show();
		  $('#xiaoe_xiaoe').hide();
	  })
	  <#if models?? && models["xiaoe"]?? && models["xiaoe"] == true>
	  form.on('radio(xiaoe)' , function(data){
		  $('#res_text').hide();
		  $('#res_inter').hide();
		  $('#res_skill').hide();
		  $('#xiaoe_xiaoe').show();
	  })
	  </#if>
	  form.on('radio(inter)' , function(data){
		  $('#res_text').hide();
		  $('#res_inter').show();
		  $('#res_skill').hide();
	  })
	  form.on('select(event)' , function(data){
		  if(data.value == 'click'){
		  	$('#in_keyword').show();
	  	  }else{
	  		$('#in_keyword').hide();  
	  	  }
	  })
	  form.on('radio(agent_default)' , function(data){
		  $('#agent_skill').hide();
		  $('#agent_agent').hide();
	  })
	  form.on('radio(agent_skill)' , function(data){
		  $('#agent_skill').show();
		  $('#agent_agent').hide();
	  })
	  form.on('radio(agent_agent)' , function(data){
		  $('#agent_skill').hide();
		  $('#agent_agent').show();
	  })
	});
</script>